<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class PmFileMappingResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  Request              $request
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'code' => $this->code,
            'name' => $this->name,
            'full_path' => fileFullPath($this->file->path),
            'year' => $this->year,
            'project_stage' => $this->project_stage,
            'project_id' => $this->project_id,
            'project_name' => $this->project->name ?? '',
            'creator' => $this->creator,
            'creator' => $this->sysUser->username ?? '',
            'approve_id' => $this->approve_id,
            'process_instance_id' => $this->approve->process_instance_id ?? '',
            'created_at' => $this->created_at?->toDateTimeString(),
            'updated_at' => $this->updated_at?->toDateTimeString(),
        ];
    }
}
